home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
bcsrce2.zip
/
BATREAD.SRC
< prev
next >
Wrap
Text File
|
1990-11-21
|
9KB
|
206 lines
echo off
rem ECHO %0 includes full file name such (Drive:\Dir\Sub\BATREAD.COM) in
rem ECHO all uppercase.
rem ********************************************************************
rem Trap for a 'help' parameter. Use of ? or /? doesn't work.
FOR %%H IN (help Help HELP /h /H) DO IF %1==%%H GOTO HELP
rem ********************************************************************
rem BATREAD, example, by Felix A. Rozewicz. All rights and responsibilities
rem for this program are vacated by myself.
rem This program is an example of how to use BAT2EXEC to do one of two
rem actions: 1) pause after each screen's worth of echos, 2) echo
rem continuously.
rem ********************************************************************
GOTO TOP
:TOP
rem *** If no parameter, at all, create environment variable '_' = '2'.
IF !%1==! SET _=2
IF !%1==! GOTO LABEL1
rem *** If any parameter, at all, create environment variable '_' = 'A'.
rem *** 'A' stands for VIEW ALL.
SET _=A
GOTO LABEL1
:LABEL1
IF %_%==2 cls
echo BAT2EXEC
echo
echo Doug Boling - Volume 9, Issue 14 - August 1990
echo
echo Purpose: Compile your batch files for added speed. Large batch
echo files often run annoyingly slowly. Compiling them with
echo BAT2EXEC will increase both your productivity and satisfaction.
echo
echo
echo Daily PC operations are almost unimaginable without the use of batch
echo files. Everyone has his favorite collection of them, and some users
echo have constructed complex batch files of thousands of bytes that push
echo the batch langauge itself to its limits. Programs that expand the
echo available batch file functions, such as Michael Mefford's BATCHMAN,
echo encourage users to make even larger batch files.
echo
echo Unfortunately, however, batch files are also notoriously slow.
echo It can be almost painful to watch them scroll down the screen a line
echo at a time. A standard way to improve the speed of interpreted
echo programs, such as batch files, is to compile them. That's where
echo BAT2EXEC comes in.
echo
IF %_%==2 PAUSE
IF %_%==2 CLS
GOTO LABEL2
:LABEL2
echo USING BAT2EXEC
echo
echo The full syntax for BAT2EXEC could hardly be simpler. Just enter:
echo
echo BAT2EXEC FILE.BAT
echo
echo where FILE.BAT is the name of your batch file. BAT2EXEC will then
echo produce an executable .COM file with the name FILE.COM. If BAT2EXEC
echo can't find the batch file, an error message will be printed. If
echo BAT2EXEC can't understand a line in the batch file, it will print an
echo error message indicating the line in the file in which it discovered
echo the error.
echo
echo BAT2EXEC should not be used on every batch file. AUTOEXEC.BAT, for
echo example, must remain a genuine batch file in order for COMMAND.COM to
echo find it. Similarly, batch files that run terminate and stay resident
echo utilities (TSRs) should not be compiled. The reason for this
echo limitation lies in the DOS memory management structure: if a TSR is
echo executed from a program compiled by BAT2EXEC, the memory used by
echo BAT2EXEC itself will not be made available to the system after
echo it terminates.
IF %_%==2 PAUSE
IF %_%==2 CLS
GOTO LABEL3
:LABEL3
echo
echo Programs created by BAT2EXEC behave slightly differently from the
echo batch files from which they were compiled. The .COM file does not
echo echo each line to the screen as does the batch file, for example.
echo Running other batch files does not cause the .COM program to end.
echo Also, pressing Ctrl-Break does not present the message, "Terminate
echo Batch file (y/n)." If Ctrl-Break is pressed and BREAK has been set
echo on, the program simply terminates.
echo
echo The size of the resulting .COM file is somewhat larger than
echo the batch file. Compiling a batch file containing a single REM
echo statement results in a .COM file size of 68 bytes, illustrating the
echo overhead of the setup and terminate routines. Program size increases
echo quickly as routines are added then slows as the loaded routines are
echo reused instead of new ones being added.
echo
echo Certainly, BAT2EXEC is not suitable for use on every batch
echo file. Two and three line batch files are best left in their easy-to-
echo alter and simple-to-understand ASCII format. However, for those batch
echo files that have grown into long complex programs, BAT2EXEC is the
echo answer.
IF %_%==2 PAUSE
IF %_%==2 CLS
rem *** Here we cut off from the continuous option. If '_' = 'A', we
rem *** terminate the program. In effect, you can recreate the original
rem *** BAT2EXEC.DOC in this manner. This is true for LABEL4-LABEL7.
IF %_%==A GOTO END
GOTO LABEL4
:LABEL4
echo In the (recent) past, I have, justifiably, criticized PC Magazine's
echo BAT2EXEC.COM program. The revised, version 1.2, program is no longer
echo so problematic. Douglas Boling got it, nearly, right this time. He
echo has fixed the crippling problem of not supporting redirection. While
echo it doesn't replace a sturdy utility like BATCOM or Power Batch, there
echo are some types of .BAT programs that it is VERY useful for.
echo .
echo If you have a .BAT that consists, predominately, of sections like
echo the below, it can be indispensible:
echo :MARK
echo ECHO SYNTAX--: MARK [TSR NAME]
echo ECHO USAGE---: Marks current memory state to later RELEASE named TSR
echo ECHO SAMPLE SEQUENCE: MARK SIDEKICK
echo ECHO SIDEKICK
echo ECHO {series of commands, etcetera}
echo ECHO RELEASE SIDEKICK
echo ECHO WARNING: MARKed TSR's MUST be RELEASEd in reverse order ALWAYS.
echo ECHO Note: MARK uses more memory than FMARK, but is more powerful.
echo ECHO [TSR NAME] is purely optional.
echo ECHO TSR= Terminate Stay Resident
echo GOTO END
IF %_%==2 PAUSE
IF %_%==2 CLS
IF %_%==A GOTO END
GOTO LABEL5
:LABEL5
echo .
echo BAT2EXEC, 1.2, writes to STDOUT. Therefor, you can redirect ECHOs
echo to NUL, File, CON, PRN, LPT1, etcetera. The speed of finding a
echo label is quite acceptable.
echo .
echo To maximize an online help, as the above example illustrates, you
echo can use a sequence like this:
echo BAT2EXEC Syntax.BAT
echo COMTOEXE Syntax
echo LZEXE Syntax
echo ERASE Syntax.COM
echo ERASE Syntax.OLD
echo This will, effectively, cut the file size in half. This can be quite
echo vital in a system without a hard drive (Laptop, dual floppy).
echo .
IF %_%==2 PAUSE
IF %_%==2 CLS
IF %_%==A GOTO END
GOTO LABEL6
:LABEL6
echo There are some alterations to, usual, BAT programming techniques that
echo should be made. Foremost, is the practice of following ECHO with a
echo single character, no space (ECHO., ECHO/, ECHO\) to achieve a blank
echo line. All of these should be rewrittened to ECHO, one space, plus
echo ASCII character 255. Also, BAT2EXEC is not forgiving of sloppy code.
echo If you have two labels with the same name, a .COM file will not be
echo compiled. This is also true if you have a GOTO Labelname but Label-
echo name doesn't exist.
echo .
echo If it stumbles on something like GOTO END, try doing a global replace
echo on all ENDs to STOP (and vice-a-versa). Strangely, I have had this
echo problem show up.
echo .
echo In effect, you could use BAT2EXE as a debugging tool since it does
echo give you some error messages. Not bad for 6.125K disk storage.
echo .
IF %_%==2 PAUSE
IF %_%==2 CLS
IF %_%==A GOTO END
GOTO LABEL7
:LABEL7
echo Some uses that come to immediate mind would be a consolidation of
echo single screen reference files previously made with MAKECOM.BAS:
echo 1) Postal State Abreviations
echo 2) Printer codes for a specific printer
echo 3) ANSI.SYS commands
echo 4) The extended IBM character sets
echo 5) dBASE INKEY/READKEY/ON LABEL lists
echo By doing this, you can